const context = require.context("./dir", true, /\.js$/);

export default {
    install(Vue, options) {
        if (options && options.directives) {
            let directives = options.directives;
            directives.forEach((v) => {
                let arr = context.keys();
                let contextFilter = arr.filter((key) => context(key).default.name === v);
                contextFilter.forEach((v) => {
                    Vue.directive(context(v).default.name, context(v).default);
                });
            });
        } else {
            context.keys().forEach((v) => {
                Vue.directive(context(v).default.name, context(v).default);
            });
        }
    },
};
